/*    */ package com.zimbra.cs.service.account;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AccountConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.StringUtil;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ModifyWhiteBlackList
/*    */   extends AccountDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 33 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 34 */     Account account = getRequestedAccount(zsc);
/*    */     
/* 36 */     if (!canModifyOptions(zsc, account)) {
/* 37 */       throw ServiceException.PERM_DENIED("can not modify options");
/*    */     }
/* 39 */     HashMap<String, Object> addrs = new HashMap();
/*    */     
/* 41 */     doList(request.getOptionalElement("whiteList"), "amavisWhitelistSender", addrs);
/*    */     
/*    */ 
/*    */ 
/* 45 */     doList(request.getOptionalElement("blackList"), "amavisBlacklistSender", addrs);
/*    */     
/*    */ 
/*    */ 
/*    */ 
/* 50 */     Provisioning.getInstance().modifyAttrs(account, addrs, true, zsc.getAuthToken());
/*    */     
/* 52 */     Element response = zsc.createElement(AccountConstants.MODIFY_WHITE_BLACK_LIST_RESPONSE);
/* 53 */     return response;
/*    */   }
/*    */   
/*    */   private void doList(Element eList, String attrName, HashMap<String, Object> addrs) {
/* 57 */     if (eList == null) {
/* 58 */       return;
/*    */     }
/*    */     
/* 61 */     if (eList.getOptionalElement("addr") == null) {
/* 62 */       StringUtil.addToMultiMap(addrs, attrName, "");
/* 63 */       return;
/*    */     }
/*    */     
/* 66 */     for (Element eAddr : eList.listElements("addr")) {
/* 67 */       String attr = eAddr.getAttribute("op", "") + attrName;
/* 68 */       String value = eAddr.getText();
/* 69 */       StringUtil.addToMultiMap(addrs, attr, value);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/ModifyWhiteBlackList.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */